#include "Player.hpp"

void Player::bind(lua_State* luaState){
	luabind::module(luaState)[
        luabind::class_<Player>("Player")
			.def_readonly("index", &Player::index)
			.def_readwrite("x", &Player::x)
            .def_readwrite("y", &Player::y)
			.def_readwrite("maxVelocityX", &Player::maxVelocityX)
			.def_readwrite("maxVelocityY", &Player::maxVelocityY)
			.def_readwrite("acceleration", &Player::acceleration)
			.def("setMove", &Player::setMove)
			.enum_("constant")[
				luabind::value("North", Entity::dir_N),
				luabind::value("East", Entity::dir_E),
				luabind::value("South", Entity::dir_S),
				luabind::value("West", Entity::dir_W)
			]
    ];
}

void Player::push(lua_State* luaState){
	luabind::object o = luabind::object(luaState, this);
    o.push(luaState);
}

/** 
* Update player state.
*/
void Player::update(){
    move();
    region->x = x - region->width/2;
    region->y = y - region->height/2;
}
